// 引入mongoose模块
const mongoose = require('mongoose')
// 连接本地数据库
mongoose.connect('mongodb://localhost/blog')

// 定义数据模型
const commentSchema = mongoose.Schema({
  nickName: String,
  email: String,
  content: String,
  add_time: String,
  articleId: String,
  articleTitle: String,
  commentType: Number,
  children: Array
}, { collection: 'comments' })
// 上面第二个参数指定到数据库的articles表中取数据

// 导出model模块
const Comment = module.exports = mongoose.model('comments', commentSchema)
